from typing import List


class Solution:
    def productExceptSelf(self, nums: List[int]) -> List[int]:
        resList = [1]*len(nums)

        left, right = 1, 1
        for i in range(len(nums)):
            resList[i] = left*resList[i]
            left = left * nums[i]

        for k in range(-1, -1*(len(nums)+1), -1):
            resList[k] = right*resList[k]
            right = right*nums[k]

        return resList


print(Solution().productExceptSelf([1, 2, 3, 4, 8]))
